import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    //别名
    alias:'/home_page',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.      懒加载
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path:'/signIn',
    name:'SignIn',
    component:() => import('@/views/SignIn.vue')
  },
  {
    path:'/argu/:name',
    name:'Argu',
    component:() => import('@/views/Argu.vue')
  },
  //嵌套路由
  {
    path:'/parent',
    name:'Parent',
    component:()=>import('../views/Parent.vue'),
    children:[
      {
        //子路由在脚手架中不能加 /
        path:'child',
        component:()=>import('../views/Child.vue')
      }
    ]
  },
  //命名路由
  {
    path:'/named_view',
    components:{
      //加载多个组件
      default:()=>import('../views/Child.vue'),
      email:()=>import('../views/Emile.vue'),
      tel:()=>import('../views/Tel.vue'),
    }
  },
  //路由的重定向
  {
    path:'/mama',
    // redirect:{
    //   name:'Home'
    // }
    redirect:'/'
  }
]

const router = new VueRouter({
  routes
})

export default router
